<?
header('content-type:text/html;charset=utf-8');
class Admin_Index_Controller extends Base_Controller {


 public function action_index()
    {   

        $s = (Input::get('s'));
        $s1 = (Input::get('s1')); 
        $username = Session::get('username');

        if($s||$s1){

            $users = DB::table('user')
                ->where_between('regtime',strtotime($s),strtotime($s1))
                ->order_by('id','asc')->paginate(5);;              
        }else{
            $users = DB::table('user')
                    ->order_by('id','asc')->paginate(5);;  
        }  
        return View::make('admin/index',array('username'=>$username,'users'=>$users,'s'=>$s,'s1'=>$s1));
       
    }

    public function action_change()
    {   
        $id = $_GET['id'];
        $username = Session::get('username');
        $res = DB::table('user')->where('id','=',$id)->first();
        return View::make('admin/userchange',array('username'=>$username,'res'=>$res));
       
    }

     public function action_douserchange()
    {   
        $id = Input::get('id');
        $username   = Input::get('username');
        $email = Input::get('email');
        $phone = Input::get('phone');
        $password = Input::get('password');
        $date = Input::get('date');
        $regtime = strtotime($date);
        $res = DB::table('user')->where('id','=',$id)->update(array('username' =>$username,'email'=>$email,'phone'=>$phone,'password'=>$password,'regtime'=>$regtime));
       if($res){
            return View::make('jump/error2',array('msg'=>'修改成功.....','time'=>2,'url'=>'index'));
       }else{
            return View::make('jump/error',array('msg'=>'修改失败','time'=>3));
       }
    }

     public function action_dele()
    {   
        $id = $_GET['id'];
        $username = Session::get('username');
        $tr = DB::table('user')->where('id','=',$id)->delete();
        if($tr){
            return View::make('jump/error2',array('msg'=>'删除成功.....','time'=>1,'url'=>'index'));
        }else{
            return View::make('jump/error',array('msg'=>'删除失败','time'=>3));
        }    
    }





    
}